package com.tocea.formation.tpLibraryEjb.util;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.Stateless;

import com.tocea.formation.tpLibraryEjb.DTO.BookDTO;
import com.tocea.formation.tpLibraryEjb.entities.Book;

@Stateless
public class BookConvert {
	public BookConvert(){}

	public static BookDTO convert(Book a){
		a = new Book();
		return new BookDTO(a.getId(), a.getName(), a.getGenre(), AuthorConvert.convert(a.getAuthor()), a.getIsbn(), a.getExemplaires());
	}
	
	public static List<BookDTO> convertFromListBookToListDTO(List<Book> lista){
		List<BookDTO> list = new ArrayList<BookDTO>();
		for (Book Book : lista) {
			list.add(BookConvert.convert(Book));
		}
		return list;
		
	}
	

}
